Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JAVA_API][GSOC] Add Java API bindings #709

Merged
merged 20 commits into from
Dec 12, 2023

Conversation

rajatkrishna
Copy link
Contributor

Details

This PR adds JNI wrappers to the OpenVINO Java API and includes a hello_query_device sample that demonstrates the usage of the Query Device API feature to print device configuration and default config values.

Below is a list of JNI wrappers added:

  • Read and compile a model directly from the model path

    ov::Core Core
    compile_model(model_path) compile_model(modelPath)
    compile_model(model_path, device_name) compile_model(modelPath, deviceName)
    compile_model(model_path, device_name, properties={}) compile_model(modelPath, deviceName, properties)
  • Compile an ov.Model with the given properties

    ov::Core Core
    compile_model(model, device_name, properties={}) compile_model(model, deviceName, properties)
  • List devices available for inference

    ov::Core Core
    get_available_devices() get_available_devices()
  • Extract data from ov.Any type

    ov::Any Any
    asString()
    asList()
  • List the input and output tensor information of a CompiledModel. Returns the tensor shape, name and element type of each input/output tensor.

    ov::CompiledModel CompiledModel
    inputs() inputs()
    outputs() outputs()
  • Set input/output tensors to infer on by tensor name when the model has multiple input/output tensors

    ov::InferRequest InferRequest
    set_tensor(tensor_name, tensor) set_tensor(tensorName, tensor)
  • Create integer tensors and extract data as an int array

    ov::Tensor Tensor
    Tensor(shape, data) Tensor(shape, data)
    data() as_int()
  • Create Long tensors

    ov::Tensor Tensor
    Tensor(shape, data) Tensor(shape, data)
  • Save model into IR format from memory

    ov::serialize(model, xml_path, bin_path) Openvino.serialize(model, xmlPath, binPath)

@rajatkrishna rajatkrishna requested a review from a team as a code owner August 24, 2023 16:35
@github-actions github-actions bot added the category: java API OpenVINO Runtime Java API label Aug 24, 2023
@ravi9 ravi9 requested review from ngaloppo, ravi9 and likholat August 24, 2023 18:05
modules/java_api/src/main/cpp/infer_request.cpp Outdated Show resolved Hide resolved
modules/java_api/src/main/cpp/jni_common.hpp Outdated Show resolved Hide resolved
modules/java_api/src/main/cpp/jni_common.hpp Outdated Show resolved Hide resolved
modules/java_api/src/main/cpp/openvino.cpp Show resolved Hide resolved
modules/java_api/src/main/cpp/openvino.cpp Show resolved Hide resolved
@likholat
Copy link
Contributor

likholat commented Dec 7, 2023

@rajatkrishna please run google-java-format locally before commit:

cd openvino_contrib/modules/java_api
find . -name "*.java" -type f -print | xargs java -jar google-java-format-1.18.1-all-deps.jar -i -a

@likholat
Copy link
Contributor

@ilya-lavrenov could you merge this PR?

@ilya-lavrenov ilya-lavrenov merged commit 9efd0b0 into openvinotoolkit:master Dec 12, 2023
5 checks passed
@rajatkrishna rajatkrishna deleted the ov-java-api branch December 12, 2023 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: java API OpenVINO Runtime Java API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants